import { QL } from 'iflux2'

//将订单状态合入订单数据中
export const listQL = QL('listQL', [
    'list',
    'orderMapStatus',
    'comments',
    'replies',
    (list, orderMapStatus, comments, replies) =>
        list.map(trade => {
            // 将评论和回复设置到商品单
            let itemOrders = trade.get('itemOrders').map(order => {
                let comment = comments.get(order.get('oid'));
                if (comment) {
                    return order.set('comment', comment)
                        .set('replies', replies.get(comment.get('id')))
                }
                return order;
            })
            return trade.set('key', trade.get('tid'))
                .set('orderStatus', orderMapStatus.get(trade.get('tid')))
                .set('itemOrders', itemOrders)
        })
])